import { SuperEntity } from '../common/types'
type DbType =
  | 'MYSQL'
  | 'POSTGRESQL'
  | 'HIVE'
  | 'KAFKA'
  | 'CLICKHOUSE'
  | 'ORACLE'
  | 'SQLSERVER'
  | 'HDFS'
  | 'DB2'
  | 'PRESTO'
  | 'SPARK'
  | 'H2'
  | 'REDSHIFT'
  | 'YARN'
  | 'FLINKSQL'
  | 'FILE'
interface DatasourceInfo extends SuperEntity {
  name: string
  description: string
  datasourceType: DbType
  host: string
  port: string
  dbName: string
  username: string
  password: string
  other: string
  driver: string
  keytabUrl: string
  krb5ConfUrl: string
  isSys: boolean
}
interface DatabaseInfo extends SuperEntity {
  datasourceId: number
  datasourceType: DbType
  datasourceName: string
  dbName: string
  owner: string
  remark: string
}
interface ColumnInfo {
  columnName: string
  dataType: string
  args: string
  isNotNull: boolean
  defVal: string
  isPrimkey: boolean
  isPartition: boolean
  columnComment: string
  previewData: string
  newField?: boolean
}
interface IndexInfo {
  indexName: string
  isUnique: boolean
  columns: string
}
interface TableInfo extends SuperEntity {
  datasourceId: number
  datasourceType: DbType
  databaseId: number
  dbName: string
  tableName: string
  tableComment: string
  ddl: string
  columns: Array<ColumnInfo>
  indexs: Array<IndexInfo>
  previewData: string
  owner: string
  remark: string
}

interface UserTablePrivilege extends SuperEntity {
  datasourceId: number
  dbName: string
  tableName: string
  proId: number
  proName: string
  userId: number
  username: string
  privilege: string[]
}
interface ProTablePrivilege extends SuperEntity {
  datasourceId: number
  dbName: string
  tableName: string
  proId: number
  proName: string
  privilege: string[]
}

interface CreateTableEntity {
  datasourceId: number
  dbName: string
  reason: string
  mode: string
  ddl: string
  tableInfo: TableInfo
  previewData: string
}

interface TableDataRelated extends SuperEntity {
  sourceDatasourceId: number
  sourceDbType: DbType
  sourceDatasourceName: string
  sourceDbName: string
  sourceTableName: string
  sourceTable: string
  targetDatasourceId: number
  targetDbType: DbType
  targetDatasourceName: string
  targetDbName: string
  targetTableName: string
  targetTable: string
  taskDefinitionId: number
  taskName: string
  creator: string
}

interface DataRelatedNodeRelation {
  startNode: string
  endNode: string
  taskName: string
}
interface DataRelatedNode {
  datasourceId: number
  dbType: DbType
  datasourceName: string
  dbName: string
  tableName: string
  name: string
  depth: number
}
export {
  DbType,
  DatasourceInfo,
  DatabaseInfo,
  TableInfo,
  ColumnInfo,
  IndexInfo,
  UserTablePrivilege,
  ProTablePrivilege,
  CreateTableEntity,
  TableDataRelated,
  DataRelatedNodeRelation,
  DataRelatedNode
}
